/*manage the method to deal with about the user's register
 * 
 */
package software;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

import software.Mes_data;

import software.Mes_done;
public class Mes_function extends Mes_done{
	
	public Mes_data message = new Mes_data();
	public List<Mes_data> messagelist=new ArrayList();
	public Iterator iterator=messagelist.iterator(); 
	public String getCon_Message(){
		//留言内容
		return message.Con_Message;
	}

	public int getId_Use_Post()
	{
		return message.ID_Use_Post;
	}
	public int getId_Use_Get()
	{
		return message.ID_Use_Get;
	}

	public  String getTim_Message(){
		DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm"); 
		try{
			Date Day=fmt.parse(message.Tim_Message);
			String Tim_Message1=fmt.format(Day);
			return Tim_Message1;
		}catch(Exception e) {
			e.printStackTrace();
		}
		return null;
		
	}

	public int getID(){
		return message.ID;
	}
	
	public int getId_Use_Rel(){
		return message.ID_Use_Rel;
	}
	
	public Boolean getFlage(){
		//将Flage置为已看
		return message.Flage;
	}
	
	public void setCon_Message(String s){
		message.Con_Message=s;
	}
	public void setId_Use_Post(int s){
		message.ID_Use_Post=s;
	}
	public void setId_Use_Get(int s){
		message.ID_Use_Get=s;
	}
	public void setTim_Message(String s){
		//设置注册邮箱
		message.Tim_Message=s;
	}
	public void setId_Use_Rel(int s){
		//设置注册邮箱
		message.ID_Use_Rel=s;
	}
	public void setFlage(){
		//将Flage置为已看
		message.Flage=true;
	}
	
	public void Mes_insert(){
		Mes_insert(message.ID_Use_Post,message.ID_Use_Get,message.ID_Use_Rel,message.Con_Message,message.Tim_Message,message.Flage);
	}
	
	public void Mes_function_read(){
		messagelist=(List<Mes_data>)Mes_done_read(message.ID_Use_Get);
	}
	
	public void Mes_function_delete(int id){
		Mes_don_delete(id);
	}
	
	public int Mes_function_check__rel(int id){
		return Mes_don_check__rel(id);
	}
	
	public int get_fun_sum_message(){
		return get_don_sum_message(message.ID_Use_Get);
	}
	
	public Mes_data Mes_get_message(int i){
		this.message=Mes_get_message(i,messagelist);
		return this.message;
		}
	
	//设置this.message，分页显示留言时利用
	public void setmessage(Mes_data s){
		this.message=s;
	}
	
	public void getfirstmessage(){
		this.message=(Mes_data)messagelist.get(0);
	}
	
	//查询主人对留言的回复的内容和时间
	public void read_message_rel(int relId){
		this.message=Mes_rel_read(relId);
	}
	
//	//测试
//	  public static void main(String[] args){
//		Mes_function ff = new Mes_function();
//		ff.setId_Use_Get(1);
//		ff.Mes_function_read();
//		ff.message=(Mes_data) ff.messagelist.get(0);
//		System.out.print(ff.getCon_Message());
//	}
	
}